#define DEBUG
#include <cstdio>

using namespace std;

const int maxn=200000, inf=0x7ffffff;

int min(int a, int b) {
  return a<b ? a : b;
}

int max(int a, int b) {
  return a>b ? a : b;
}

class SegmentTree {
public:
  int minv[4*maxn+1], maxv[4*maxn+1];

  void set(int o, int l, int r, int t, int tv) {
    if (l==r) {
      minv[o] = maxv[o] = tv;
    } else {
      int mid=(l+r)/2;
      if (t<=mid) {
	set(o*2, l, mid, t, tv);
      } else {
	set(o*2+1, mid+1, r, t, tv);
      }
      minv[o] = min(minv[o*2], minv[o*2+1]);
      maxv[o] = max(maxv[o*2], maxv[o*2+1]);
    }
  }

  int getMin(int o, int l, int r, int tl, int tr) {
    if (l==tl && r==tr) {
      return minv[o];
    } else {
      int mid=(l+r)/2, ret=inf;
      if (tl<=mid && tr>=l) {
	ret = min(ret, getMin(o*2, l, mid, max(tl, l), min(tr, mid)));
      }
      if (tl<=r && tr>mid) {
	ret = min(ret, getMin(o*2+1, mid+1, r, max(tl, mid+1), min(tr, r)));
      }
      return ret;
    }
  }

  int getMax(int o, int l, int r, int tl, int tr) {
    if (l==tl && r==tr) {
      return maxv[o];
    } else {
      int mid=(l+r)/2, ret=0;
      if (tl<=mid && tr>=l) {
	ret = max(ret, getMax(o*2, l, mid, max(tl, l), min(tr, mid)));
      }
      if (tl<=r && tr>mid) {
	ret = max(ret, getMax(o*2+1, mid+1, r, max(tl, mid+1), min(tr, r)));
      }
      return ret;
    }
  }
};

int main() {
#ifdef DEBUG
  freopen("0.in", "r", stdin);
  freopen("0.out", "w", stdout);
#endif

  static SegmentTree sgt;
  static int dwarf[maxn+1];
  int n, m;
  scanf("%d %d", &n, &m);
  for (int i=1; i<=n; i++) {
    scanf("%d", dwarf+i);
    sgt.set(1, 1, n, dwarf[i], i);
  }
  for (int i=1; i<=m; i++) {
    int opt, x, y;
    scanf("%d %d %d", &opt, &x, &y);
    if (opt==1) {
      int temp;
      temp=dwarf[x], dwarf[x]=dwarf[y], dwarf[y]=temp;
      sgt.set(1, 1, n, dwarf[x], x);
      sgt.set(1, 1, n, dwarf[y], y);
    } else {
      printf(sgt.getMax(1, 1, n, x, y)-sgt.getMin(1, 1, n, x, y)==y-x ? "YES\n" : "NO\n");
    }
  }

  fclose(stdin);
  fclose(stdout);
  return 0;
}
